//
//  YRecommendeBookListDetailCell.m
//  Reader
//
//  Created by yuemei on 2019/5/22.
//  Copyright © 2019 SF. All rights reserved.
//

#import "YRecommendeBookListDetailCell.h"
#import "YRecommendListDetailBookSubModel.h"

@interface YRecommendeBookListDetailCell()
@property (nonatomic, strong) UIImageView *coverImg;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *nickLab;
@property (nonatomic, strong) UILabel *hotLab;
@property (nonatomic, strong) UILabel *hintLab;
@end
@implementation YRecommendeBookListDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = HexColor(0xf7f7f7, 1);
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    [self.contentView addSubview:self.coverImg];
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.nickLab];
    [self.contentView addSubview:self.hotLab];
    [self.contentView addSubview:self.hintLab];
    
    [_coverImg makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).inset(15);
        make.left.equalTo(self.contentView).inset(18);
        make.size.equalTo(CGSizeMake(68, 85));
    }];
    [_titleLab makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.coverImg);
        make.left.equalTo(_coverImg.mas_right).inset(10);
    }];
    [_nickLab makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLab.mas_bottom).inset(10);
        make.left.equalTo(_coverImg.mas_right).inset(10);
    }];
    [_hotLab makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nickLab.mas_bottom).inset(10);
        make.left.equalTo(_coverImg.mas_right).inset(10);
    }];
    [_hintLab makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.coverImg.mas_bottom).inset(10);
        make.left.equalTo(self.contentView).inset(18);
        make.right.equalTo(self.contentView).inset(18);
    }];
}

-(void)setModel:(YRecommendListDetailBookSubModel *)model{
    _model = model;
   
    [self.coverImg sd_setImageWithURL:[YURLManager getURLWith:YAPITypeBookCover parameter:model.book.cover] placeholderImage:kImageDefaltBookCover];
    self.titleLab.text = model.book.title;
    self.nickLab.text = model.book.author;
    self.hotLab.text = [NSString stringWithFormat:@"%zd 人在追      %@",model.book.latelyFollower,model.book.cat];
    self.hintLab.text = [NSString stringWithFormat:@"“%@”",model.comment];
    
}

-(UIImageView *)coverImg{
    if (!_coverImg) {
        _coverImg = [UIImageView new];
    }
    return _coverImg;
}

-(UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
        _titleLab.textColor = HexColor(0x333333,1);
    }
    return _titleLab;
}

-(UILabel *)nickLab{
    if (!_nickLab) {
        _nickLab = [UILabel new];
        _nickLab.font = [UIFont systemFontOfSize:12];
        _nickLab.textColor = HexColor(0x999999,1);
    }
    return _nickLab;
}

-(UILabel *)hotLab{
    if (!_hotLab) {
        _hotLab = [UILabel new];
        _hotLab.font = [UIFont systemFontOfSize:12];
        _hotLab.textColor = HexColor(0xa3a3a3,1);
    }
    return _hotLab;
}


-(UILabel *)hintLab{
    if (!_hintLab) {
        _hintLab = [UILabel new];
        _hintLab.font = [UIFont systemFontOfSize:13];
        _hintLab.textColor = HexColor(0x777777,1);
        _hintLab.numberOfLines = 0;
    }
    return _hintLab;
}


@end
